/* 
 * File:   WiimoteManager.h
 * Author: rtintor
 *
 * Created on 24 de septiembre de 2009, 10:04 AM
 */

#ifndef _WIIMOTEMANAGER_H
#define	_WIIMOTEMANAGER_H

    /* button codes */
    #define WIIMOTE_BUTTON_TWO          0x0001
    #define WIIMOTE_BUTTON_ONE          0x0002
    #define WIIMOTE_BUTTON_B		0x0004
    #define WIIMOTE_BUTTON_A		0x0008
    #define WIIMOTE_BUTTON_MINUS	0x0010
    #define WIIMOTE_BUTTON_ZACCEL_BIT6	0x0020
    #define WIIMOTE_BUTTON_ZACCEL_BIT7	0x0040
    #define WIIMOTE_BUTTON_HOME		0x0080
    #define WIIMOTE_BUTTON_LEFT		0x0100
    #define WIIMOTE_BUTTON_RIGHT	0x0200
    #define WIIMOTE_BUTTON_DOWN		0x0400
    #define WIIMOTE_BUTTON_UP		0x0800
    #define WIIMOTE_BUTTON_PLUS		0x1000
    #define WIIMOTE_BUTTON_ZACCEL_BIT4	0x2000
    #define WIIMOTE_BUTTON_ZACCEL_BIT5	0x4000
    #define WIIMOTE_BUTTON_UNKNOWN	0x8000
    #define WIIMOTE_BUTTON_ALL		0x1F9F

typedef struct wmCallbacks{
    int (*wmButtonPressedAction)(  int wmButton /*Constant to specify the pressed wiimote code button*/,
                                    int wmID /*Wiimote ID*/);
    int (*wmButtonReleasedAction)(  int wmButton /*Constant to specify the released wiimote code button*/,
                                    int wmID /*Wiimote ID*/);
    int (*wmAccelerometerAction)(   float roll /* roll angles*/,
                                    float pitch	/* pitch angle*/,
                                    float yaw /*yaw angle*/,
                                    int wmID /*Wiimmote ID*/);
    int (*wmIRAction)(              int x /* X virtual screen coordinate*/,
                                    int y /* Y virtual screen coordinate*/,
                                    int point /* Point number localized*/,
                                    int wmID /*Wiimmote ID*/);
}wmCallbacks;

    //TODO documentar estas funciones
    int initWiimoteListening();
    void enableWMSupport();
    void wmButtonPressedFunc(int (*retroLlamada)(int wmButton, int wmID));
    void wmButtonReleasedFunc(int (*retrollamada)(int wmButton, int wmID));
    void wmAccelerometerFunc(int (*retroLlamada)(float roll, float pitch, float yaw, int wmID));
    void wmIRFunc(int (*retroLlamada)(  int x, int y, int point, int wmID));
    void toogleWMMotion(int wmID);
    void toogleWMRumble(int wmID);
    float getWMBatteryStatus(int wmID);
    int getNumberOfConnectedWM();
    void wmCleanup();


#endif	/* _WIIMOTEMANAGER_H */

